#include "stdafx.h"
#include "DEQ.H"

DEQCtrl::DEQCtrl(void)
{
	dflag.OnOff=FALSE;
	dflag.Fc[0]   		=62;	
	dflag.Q[0]		=9;
	dflag.fil_tpye[0] 	=1;
	dflag.Gain[0]	=0;
	dflag.Fc[1]  		=250;	
	dflag.Q[1]		=9;
	dflag.fil_tpye[1] 	=1;
	dflag.Gain[1]	=0;
	dflag.Fc[2]   		=1000;	
	dflag.Q[2]		=9;
	dflag.fil_tpye[2] 	=1;
	dflag.Gain[2]	=0;											
	dflag.Fc[3]   		=4000;	
	dflag.Q[3]		=9;
	dflag.fil_tpye[3] 	=1;
	dflag.Gain[3]	=0;
	dflag.Fc[4]   		=16000;	
	dflag.Q[4]		=9;
	dflag.fil_tpye[4] 	=1;						
	dflag.Gain[4]	=0;	

	memcpy((void*)&UserEQ,(void*)&dflag, sizeof(DEQDynamicFlag));
}

int DEQCtrl::GetMaxGain(void)
{
	return 12;
}

int DEQCtrl::GetMinGain(void)
{
	return -12;
}

int DEQCtrl::GetUserEQGain(int Band)
{
	return UserEQ.Gain[Band];
}

int DEQCtrl::GetCurrentMaxBand()
{
	return 5;
}

void DEQCtrl::SetUSerEQGain(int Band,int Gain)
{
	UserEQ.OnOff = true;
	UserEQ.Gain[Band] = Gain;
}

int *DEQCtrl::GetUSerEQGainChain()
{
	return UserEQ.Gain;
}

DEQDynamicFlag DEQCtrl::GetDEQValue(int NewEQMode)
{
	switch(NewEQMode)
	{
	case EQ_MODE_USER:
		if(UserEQ.OnOff)
		{
			printf("DEQ:[%d] : User EQ\n",EQ_MODE_USER);
			return UserEQ;
		}	
	case EQ_MODE_NONE: // OFF
		dflag.OnOff=FALSE;
		dflag.Fc[0]   		=62;	
		dflag.Q[0]		=9;
		dflag.fil_tpye[0] 	=1;
		dflag.Gain[0]	=0;
		dflag.Fc[1]  		=250;	
		dflag.Q[1]		=9;
		dflag.fil_tpye[1] 	=1;
		dflag.Gain[1]	=0;
		dflag.Fc[2]   		=1000;	
		dflag.Q[2]		=9;
		dflag.fil_tpye[2] 	=1;
		dflag.Gain[2]	=0;											
		dflag.Fc[3]   		=4000;	
		dflag.Q[3]		=9;
		dflag.fil_tpye[3] 	=1;
		dflag.Gain[3]	=0;
		dflag.Fc[4]   		=16000;	
		dflag.Q[4]		=9;
		dflag.fil_tpye[4] 	=1;						
		dflag.Gain[4]	=0;	
		printf("DEQ[%d] : Off\n",EQ_MODE_NONE);
		break;
	case EQ_MODE_ROCK: // ROCK
		dflag.OnOff=TRUE;
		dflag.Fc[0]   		=100;	
		dflag.Q[0]		=9;
		dflag.fil_tpye[0] 	=0;
		dflag.Gain[0]	=6;
		dflag.Fc[1]   		=600;	
		dflag.Q[1]		=9-5;
		dflag.fil_tpye[1] 	=1;
		dflag.Gain[1]	=-4;
		dflag.Fc[2]   		=3000;	
		dflag.Q[2]		=9-2;
		dflag.fil_tpye[2] 	=1;
		dflag.Gain[2]	=4;											
		dflag.Fc[3]   		=12000;	
		dflag.Q[3]		=9;
		dflag.fil_tpye[3] 	=1;
		dflag.Gain[3]	=4;
		dflag.Fc[4]   		=16000;	
		dflag.Q[4]		=9;
		dflag.fil_tpye[4] 	=1;				
		dflag.Gain[4]	=0;	
		printf("DEQ[%d] : ROCK\n",EQ_MODE_ROCK);	
		break;
	case EQ_MODE_JAZZ: // JAZZ
		dflag.OnOff=TRUE;
		dflag.Fc[0]   		=80;	
		dflag.Q[0]		=9-5;
		dflag.fil_tpye[0] 	=1;
		dflag.Gain[0]	=5;
		dflag.Fc[1]  		=220;	
		dflag.Q[1]		=9;
		dflag.fil_tpye[1] 	=1;
		dflag.Gain[1]	=1;
		dflag.Fc[2]   		=3000;	
		dflag.Q[2]		=9;
		dflag.fil_tpye[2] 	=1;
		dflag.Gain[2]	=3;											
		dflag.Fc[3]   		=13000;	
		dflag.Q[3]		=9;
		dflag.fil_tpye[3] 	=1;
		dflag.Gain[3]	=4;
		dflag.Fc[4]   		=16000;					
		dflag.Q[4]		=9;
		dflag.fil_tpye[4] 	=1;				
		dflag.Gain[4]	=0;	
		printf("DEQ[%d] : JAZZ\n",EQ_MODE_JAZZ);
		break;			
	case EQ_MODE_CLASSIC: // CLASSICAL
		dflag.OnOff=TRUE;
		dflag.Fc[0]   		=80;	
		dflag.Q[0]		=9;
		dflag.fil_tpye[0] 	=0;
		dflag.Gain[0]	=2;
		dflag.Fc[1]   		=320;	
		dflag.Q[1]		=9;
		dflag.fil_tpye[1] 	=1;
		dflag.Gain[1]	=2;
		dflag.Fc[2]   		=3000;	
		dflag.Q[2]		=9-3;
		dflag.fil_tpye[2] 	=1;
		dflag.Gain[2]	=-1;											
		dflag.Fc[3]   		=13000;	
		dflag.Q[3]		=9-3;
		dflag.fil_tpye[3] 	=1;
		dflag.Gain[3]	=-3;
		dflag.Fc[4]   		=16000;					
		dflag.Q[4]		=9;
		dflag.fil_tpye[4] 	=1;				
		dflag.Gain[4]	=0;	
		printf("DEQ[%d] : Classic\n",EQ_MODE_CLASSIC);
		break;
	case EQ_MODE_POP: // POP
		dflag.OnOff=TRUE;
		dflag.Fc[0]   		=100;	
		dflag.Q[0]		=9;
		dflag.fil_tpye[0] 	=0;
		dflag.Gain[0]	=-1;
		dflag.Fc[1]   		=700;	
		dflag.Q[1]		=9-5;
		dflag.fil_tpye[1] 	=1;
		dflag.Gain[1]	=4;
		dflag.Fc[2]   		=5000;	
		dflag.Q[2]		=9;
		dflag.fil_tpye[2] 	=1;
		dflag.Gain[2]	=-1;											
		dflag.Fc[3]   		=14000;	
		dflag.Q[3]		=9;
		dflag.fil_tpye[3] 	=2;
		dflag.Gain[3]	=-2;
		dflag.Fc[4]   		=16000;					
		dflag.Q[4]		=9;
		dflag.fil_tpye[4] 	=1;
		dflag.Gain[4]	=0;	
		printf("DEQ[%d] : POP\n",EQ_MODE_POP);
		break;		
	default:
		break;
	}

	return dflag;
}